All Questions
10 questions
1vote
1answer
1kviews
Access element of array
I have the following script which retrieves info from mysql #!/bin/bash set -f IFS=$'\n' arr=($(sudo mysql -u root -h localhost -e "USE mydb;SELECT * FROM users")) for i in "${...
2votes
1answer
355views
How to extract data more Efficient in an array?
I have a directory with some text files that have data like below; I read them via a loop and put each line in an array! I don't know the correct way and if you know any better way, let me know. ...
0votes
2answers
8kviews
bash syntax error: invalid arithmetic operator (error token is ".google.com") when parsing through array
I have an array of domains that I am attempting to iterate through and check if a string from a file matches any of the domains in the array. However, when the for loop starts, I get an error line ...
1vote
1answer
856views
Reading multiple files and operating on stored Arrays
I have 2 text files "${LinkP}" and "${QuestionP}. I want to read these files and store each complete line in the respective array, IFS=$'\r\n' GLOBIGNORE='*' command eval "LinkA=($(cat "${LinkP}"))" ...
0votes
1answer
774views
bash script load an modify array from external file
I have written a script that is reading an array: recentdirs with directory names from an external config file called: defaults.cfg and the user can either chose one of the directories from the list ...
12votes
4answers
28kviews
Print all words on lines of a file in reverse order
I don't know how to make my code working for more lines. This is the original file t.txt: Hello Earth Hello Mars But I get the following output: Mars Hello Earth Hello My expected output is this: ...
2votes
2answers
828views
bash - Separate "table" values into strings in array
EDIT: I'm sorry, the output I claimed is wrong. There are more spaces than I previously thought (something happened when the output was saved to html file to remove these) The real output is as ...
-1votes
1answer
775views
How to write the bash script dynamic to print row and columns data and update the same data in the same file? [closed]
abc_hosts,pwd_host_id,pwd_host_id,hostname,ddd_status,dddd_status, start_hosts,,,,,,,,,,,,,,,,,,, ,1,o1,fhffhfh,1,1,fff,fdfd,172.33.33.33,172.30.30.12,172.30.30.11,oreere.dff,43,443343,1111,43435,...
1vote
1answer
3kviews
Problem with sed on a array containing strings containing spaces
I have a array looking like this: array=("(1 2 3) (123)" "2 31 (231)" "4 5 1 (451)" "(te)xt (1234)") This array is a example. It does not look like this but its structure is the same (the strings ...
5votes
1answer
213views
array[@] output all messed up?
I've got this code: Unix+=("Stock List") while read line; do result=$(wget -O - -o /dev/null "http://finance.yahoo.com/d/quotes.csv?s=$line&f=sl1&e=.csv" | tr ',' ' ' | tr '"' ' ') ...